import {
    region,
    website_list,
    carrierID
} from "../../../api/information";
import client from "../../../utils/oss"
import {
    reqDictionaryOptions
} from "../../../api/earlywarning"; //数据字典接口
import { dictionaryBatch } from "../../../api/waybill";
import { Message } from 'element-ui';
// 组织接口
export async function PagewebsiteList(val) {
    var params = {
        type: val,
    }
    var res = await website_list(params)
    return res
}
// 省市区三级联动 使用同步数据 将数据传递
export async function regionList(val) {
    var params = {
        pid: val,
    }
    var res = await region(params)
    return res

}
// 图片上传功能
export async function uploading(file, filename, type) {
    let url = `${type}` + "/" + `${filename}`
    // // 将文件上传的到阿里云通过文件的的第一位路径将数据添加到列表中然后将数据列表传递给后端
    var res = await client().put(url, file)
    return res
}
// 承运商接口
export async function allcarrierID() {
    var params = {
        name: ""
    }
    var res = await carrierID(params)
    return res
}
// 数据字典的接口
export async function dictionanry(val) {
    var params = {
        dictionary_code: val,
    }
    var res = await reqDictionaryOptions(params)
    return res
}
/**
 * 数据字典list 接口
 * @param {*} []
 * @returns 
 */
export async function dictionanryList(val) {
    var params = {
        codes: val,
    }
    var res = await dictionaryBatch(params)
    return res
}
// 文件下载
export async function downloadFile(url, name) {
    var link = document.createElement('a');
    var updatedUrl = url.replace('http://', 'https://');
    link.href = updatedUrl;
    link.download = name;
    // 添加一个辅助的点击事件，用于触发文件下载
    link.style.display = 'none';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
}
// 消息提醒
export function messageType(text, type) {
    // console.log("哈桑带哦有")
    return Message({
        message: text,
        type: type
    });
}